{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "## 11.5 \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684REST\u63a5\u53e3\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u95ee\u9898\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4f60\u60f3\u4f7f\u7528\u4e00\u4e2a\u7b80\u5355\u7684REST\u63a5\u53e3\u901a\u8fc7\u7f51\u7edc\u8fdc\u7a0b\u63a7\u5236\u6216\u8bbf\u95ee\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f46\u662f\u4f60\u53c8\u4e0d\u60f3\u81ea\u5df1\u53bb\u5b89\u88c5\u4e00\u4e2a\u5b8c\u6574\u7684web\u6846\u67b6\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u89e3\u51b3\u65b9\u6848\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u6784\u5efa\u4e00\u4e2aREST\u98ce\u683c\u7684\u63a5\u53e3\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u521b\u5efa\u4e00\u4e2a\u57fa\u4e8eWSGI\u6807\u51c6\uff08PEP 3333\uff09\u7684\u5f88\u5c0f\u7684\u5e93\uff0c\u4e0b\u9762\u662f\u4e00\u4e2a\u4f8b\u5b50\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "# resty.py\n\nimport cgi\n\ndef notfound_404(environ, start_response):\n    start_response('404 Not Found', [ ('Content-type', 'text/plain') ])\n    return [b'Not Found']\n\nclass PathDispatcher:\n    def __init__(self):\n        self.pathmap = { }\n\n    def __call__(self, environ, start_response):\n        path = environ['PATH_INFO']\n        params = cgi.FieldStorage(environ['wsgi.input'],\n                                  environ=environ)\n        method = environ['REQUEST_METHOD'].lower()\n        environ['params'] = { key: params.getvalue(key) for key in params }\n        handler = self.pathmap.get((method,path), notfound_404)\n        return handler(environ, start_response)\n\n    def register(self, method, path, function):\n        self.pathmap[method.lower(), path] = function\n        return function"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e3a\u4e86\u4f7f\u7528\u8fd9\u4e2a\u8c03\u5ea6\u5668\uff0c\u4f60\u53ea\u9700\u8981\u7f16\u5199\u4e0d\u540c\u7684\u5904\u7406\u5668\uff0c\u5c31\u50cf\u4e0b\u9762\u8fd9\u6837\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import time\n\n_hello_resp = '''\\\n<html>\n  <head>\n     <title>Hello {name}</title>\n   </head>\n   <body>\n     <h1>Hello {name}!</h1>\n   </body>\n</html>'''\n\ndef hello_world(environ, start_response):\n    start_response('200 OK', [ ('Content-type','text/html')])\n    params = environ['params']\n    resp = _hello_resp.format(name=params.get('name'))\n    yield resp.encode('utf-8')\n\n_localtime_resp = '''\\\n<?xml version=\"1.0\"?>\n<time>\n  <year>{t.tm_year}</year>\n  <month>{t.tm_mon}</month>\n  <day>{t.tm_mday}</day>\n  <hour>{t.tm_hour}</hour>\n  <minute>{t.tm_min}</minute>\n  <second>{t.tm_sec}</second>\n</time>'''\n\ndef localtime(environ, start_response):\n    start_response('200 OK', [ ('Content-type', 'application/xml') ])\n    resp = _localtime_resp.format(t=time.localtime())\n    yield resp.encode('utf-8')\n\nif __name__ == '__main__':\n    from resty import PathDispatcher\n    from wsgiref.simple_server import make_server\n\n    # Create the dispatcher and register functions\n    dispatcher = PathDispatcher()\n    dispatcher.register('GET', '/hello', hello_world)\n    dispatcher.register('GET', '/localtime', localtime)\n\n    # Launch a basic server\n    httpd = make_server('', 8080, dispatcher)\n    print('Serving on port 8080...')\n    httpd.serve_forever()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u8981\u6d4b\u8bd5\u4e0b\u8fd9\u4e2a\u670d\u52a1\u5668\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528\u4e00\u4e2a\u6d4f\u89c8\u5668\u6216 urllib \u548c\u5b83\u4ea4\u4e92\u3002\u4f8b\u5982\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "u = urlopen('http://localhost:8080/hello?name=Guido')\nprint(u.read().decode('utf-8'))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "u = urlopen('http://localhost:8080/localtime')\nprint(u.read().decode('utf-8'))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "### \u8ba8\u8bba\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5728\u7f16\u5199REST\u63a5\u53e3\u65f6\uff0c\u901a\u5e38\u90fd\u662f\u670d\u52a1\u4e8e\u666e\u901a\u7684HTTP\u8bf7\u6c42\u3002\u4f46\u662f\u8ddf\u90a3\u4e9b\u529f\u80fd\u5b8c\u6574\u7684\u7f51\u7ad9\u76f8\u6bd4\uff0c\u4f60\u901a\u5e38\u53ea\u9700\u8981\u5904\u7406\u6570\u636e\u3002\n\u8fd9\u4e9b\u6570\u636e\u4ee5\u5404\u79cd\u6807\u51c6\u683c\u5f0f\u7f16\u7801\uff0c\u6bd4\u5982XML\u3001JSON\u6216CSV\u3002\n\u5c3d\u7ba1\u7a0b\u5e8f\u770b\u4e0a\u53bb\u5f88\u7b80\u5355\uff0c\u4f46\u662f\u4ee5\u8fd9\u79cd\u65b9\u5f0f\u63d0\u4f9b\u7684API\u5bf9\u4e8e\u5f88\u591a\u5e94\u7528\u7a0b\u5e8f\u6765\u8bb2\u662f\u975e\u5e38\u6709\u7528\u7684\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4f8b\u5982\uff0c\u957f\u671f\u8fd0\u884c\u7684\u7a0b\u5e8f\u53ef\u80fd\u4f1a\u4f7f\u7528\u4e00\u4e2aREST API\u6765\u5b9e\u73b0\u76d1\u63a7\u6216\u8bca\u65ad\u3002\n\u5927\u6570\u636e\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u4f7f\u7528REST\u6765\u6784\u5efa\u4e00\u4e2a\u6570\u636e\u67e5\u8be2\u6216\u63d0\u53d6\u7cfb\u7edf\u3002\nREST\u8fd8\u80fd\u7528\u6765\u63a7\u5236\u786c\u4ef6\u8bbe\u5907\u6bd4\u5982\u673a\u5668\u4eba\u3001\u4f20\u611f\u5668\u3001\u5de5\u5382\u6216\u706f\u6ce1\u3002\n\u66f4\u91cd\u8981\u7684\u662f\uff0cREST API\u5df2\u7ecf\u88ab\u5927\u91cf\u5ba2\u6237\u7aef\u7f16\u7a0b\u73af\u5883\u6240\u652f\u6301\uff0c\u6bd4\u5982Javascript, Android, iOS\u7b49\u3002\n\u56e0\u6b64\uff0c\u5229\u7528\u8fd9\u79cd\u63a5\u53e3\u53ef\u4ee5\u8ba9\u4f60\u5f00\u53d1\u51fa\u66f4\u52a0\u590d\u6742\u7684\u5e94\u7528\u7a0b\u5e8f\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e3a\u4e86\u5b9e\u73b0\u4e00\u4e2a\u7b80\u5355\u7684REST\u63a5\u53e3\uff0c\u4f60\u53ea\u9700\u8ba9\u4f60\u7684\u7a0b\u5e8f\u4ee3\u7801\u6ee1\u8db3Python\u7684WSGI\u6807\u51c6\u5373\u53ef\u3002\nWSGI\u88ab\u6807\u51c6\u5e93\u652f\u6301\uff0c\u540c\u65f6\u4e5f\u88ab\u7edd\u5927\u90e8\u5206\u7b2c\u4e09\u65b9web\u6846\u67b6\u652f\u6301\u3002\n\u56e0\u6b64\uff0c\u5982\u679c\u4f60\u7684\u4ee3\u7801\u9075\u5faa\u8fd9\u4e2a\u6807\u51c6\uff0c\u5728\u540e\u9762\u7684\u4f7f\u7528\u8fc7\u7a0b\u4e2d\u5c31\u4f1a\u66f4\u52a0\u7684\u7075\u6d3b\uff01"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5728WSGI\u4e2d\uff0c\u4f60\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u7ea6\u5b9a\u7684\u65b9\u5f0f\u4ee5\u4e00\u4e2a\u53ef\u8c03\u7528\u5bf9\u8c61\u5f62\u5f0f\u6765\u5b9e\u73b0\u4f60\u7684\u7a0b\u5e8f\u3002"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "import cgi\n\ndef wsgi_app(environ, start_response):\n    pass"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "environ \u5c5e\u6027\u662f\u4e00\u4e2a\u5b57\u5178\uff0c\u5305\u542b\u4e86\u4eceweb\u670d\u52a1\u5668\u5982Apache[\u53c2\u8003Internet RFC 3875]\u63d0\u4f9b\u7684CGI\u63a5\u53e3\u4e2d\u83b7\u53d6\u7684\u503c\u3002\n\u8981\u5c06\u8fd9\u4e9b\u4e0d\u540c\u7684\u503c\u63d0\u53d6\u51fa\u6765\uff0c\u4f60\u53ef\u4ee5\u50cf\u8fd9\u4e48\u8fd9\u6837\u5199\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def wsgi_app(environ, start_response):\n    method = environ['REQUEST_METHOD']\n    path = environ['PATH_INFO']\n    # Parse the query parameters\n    params = cgi.FieldStorage(environ['wsgi.input'], environ=environ)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u6211\u4eec\u5c55\u793a\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u503c\u3002environ['REQUEST_METHOD'] \u4ee3\u8868\u8bf7\u6c42\u7c7b\u578b\u5982GET\u3001POST\u3001HEAD\u7b49\u3002\nenviron['PATH_INFO'] \u8868\u793a\u88ab\u8bf7\u6c42\u8d44\u6e90\u7684\u8def\u5f84\u3002\n\u8c03\u7528 cgi.FieldStorage() \u53ef\u4ee5\u4ece\u8bf7\u6c42\u4e2d\u63d0\u53d6\u67e5\u8be2\u53c2\u6570\u5e76\u5c06\u5b83\u4eec\u653e\u5165\u4e00\u4e2a\u7c7b\u5b57\u5178\u5bf9\u8c61\u4e2d\u4ee5\u4fbf\u540e\u9762\u4f7f\u7528\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "start_response \u53c2\u6570\u662f\u4e00\u4e2a\u4e3a\u4e86\u521d\u59cb\u5316\u4e00\u4e2a\u8bf7\u6c42\u5bf9\u8c61\u800c\u5fc5\u987b\u88ab\u8c03\u7528\u7684\u51fd\u6570\u3002\n\u7b2c\u4e00\u4e2a\u53c2\u6570\u662f\u8fd4\u56de\u7684HTTP\u72b6\u6001\u503c\uff0c\u7b2c\u4e8c\u4e2a\u53c2\u6570\u662f\u4e00\u4e2a(\u540d,\u503c)\u5143\u7ec4\u5217\u8868\uff0c\u7528\u6765\u6784\u5efa\u8fd4\u56de\u7684HTTP\u5934\u3002\u4f8b\u5982\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def wsgi_app(environ, start_response):\n    pass\n    start_response('200 OK', [('Content-type', 'text/plain')])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e3a\u4e86\u8fd4\u56de\u6570\u636e\uff0c\u4e00\u4e2aWSGI\u7a0b\u5e8f\u5fc5\u987b\u8fd4\u56de\u4e00\u4e2a\u5b57\u8282\u5b57\u7b26\u4e32\u5e8f\u5217\u3002\u53ef\u4ee5\u50cf\u4e0b\u9762\u8fd9\u6837\u4f7f\u7528\u4e00\u4e2a\u5217\u8868\u6765\u5b8c\u6210\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def wsgi_app(environ, start_response):\n    pass\n    start_response('200 OK', [('Content-type', 'text/plain')])\n    resp = []\n    resp.append(b'Hello World\\n')\n    resp.append(b'Goodbye!\\n')\n    return resp"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u6216\u8005\uff0c\u4f60\u8fd8\u53ef\u4ee5\u4f7f\u7528 yield \uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "def wsgi_app(environ, start_response):\n    pass\n    start_response('200 OK', [('Content-type', 'text/plain')])\n    yield b'Hello World\\n'\n    yield b'Goodbye!\\n'"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u8fd9\u91cc\u8981\u5f3a\u8c03\u7684\u4e00\u70b9\u662f\u6700\u540e\u8fd4\u56de\u7684\u5fc5\u987b\u662f\u5b57\u8282\u5b57\u7b26\u4e32\u3002\u5982\u679c\u8fd4\u56de\u7ed3\u679c\u5305\u542b\u6587\u672c\u5b57\u7b26\u4e32\uff0c\u5fc5\u987b\u5148\u5c06\u5176\u7f16\u7801\u6210\u5b57\u8282\u3002\n\u5f53\u7136\uff0c\u5e76\u6ca1\u6709\u8981\u6c42\u4f60\u8fd4\u56de\u7684\u4e00\u5b9a\u662f\u6587\u672c\uff0c\u4f60\u53ef\u4ee5\u5f88\u8f7b\u677e\u7684\u7f16\u5199\u4e00\u4e2a\u751f\u6210\u56fe\u7247\u7684\u7a0b\u5e8f\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5c3d\u7ba1WSGI\u7a0b\u5e8f\u901a\u5e38\u88ab\u5b9a\u4e49\u6210\u4e00\u4e2a\u51fd\u6570\uff0c\u4e0d\u8fc7\u4f60\u4e5f\u53ef\u4ee5\u4f7f\u7528\u7c7b\u5b9e\u4f8b\u6765\u5b9e\u73b0\uff0c\u53ea\u8981\u5b83\u5b9e\u73b0\u4e86\u5408\u9002\u7684 __call__() \u65b9\u6cd5\u3002\u4f8b\u5982\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "class WSGIApplication:\n    def __init__(self):\n        ...\n    def __call__(self, environ, start_response)\n       ..."
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u6211\u4eec\u5df2\u7ecf\u5728\u4e0a\u9762\u4f7f\u7528\u8fd9\u79cd\u6280\u672f\u521b\u5efa PathDispatcher \u7c7b\u3002\n\u8fd9\u4e2a\u5206\u53d1\u5668\u4ec5\u4ec5\u53ea\u662f\u7ba1\u7406\u4e00\u4e2a\u5b57\u5178\uff0c\u5c06(\u65b9\u6cd5,\u8def\u5f84)\u5bf9\u6620\u5c04\u5230\u5904\u7406\u5668\u51fd\u6570\u4e0a\u9762\u3002\n\u5f53\u4e00\u4e2a\u8bf7\u6c42\u5230\u6765\u65f6\uff0c\u5b83\u7684\u65b9\u6cd5\u548c\u8def\u5f84\u88ab\u63d0\u53d6\u51fa\u6765\uff0c\u7136\u540e\u88ab\u5206\u53d1\u5230\u5bf9\u5e94\u7684\u5904\u7406\u5668\u4e0a\u9762\u53bb\u3002\n\u53e6\u5916\uff0c\u4efb\u4f55\u67e5\u8be2\u53d8\u91cf\u4f1a\u88ab\u89e3\u6790\u540e\u653e\u5230\u4e00\u4e2a\u5b57\u5178\u4e2d\uff0c\u4ee5 environ['params'] \u5f62\u5f0f\u5b58\u50a8\u3002\n\u540e\u9762\u8fd9\u4e2a\u6b65\u9aa4\u592a\u5e38\u89c1\uff0c\u6240\u4ee5\u5efa\u8bae\u4f60\u5728\u5206\u53d1\u5668\u91cc\u9762\u5b8c\u6210\uff0c\u8fd9\u6837\u53ef\u4ee5\u7701\u6389\u5f88\u591a\u91cd\u590d\u4ee3\u7801\u3002\n\u4f7f\u7528\u5206\u53d1\u5668\u7684\u65f6\u5019\uff0c\u4f60\u53ea\u9700\u7b80\u5355\u7684\u521b\u5efa\u4e00\u4e2a\u5b9e\u4f8b\uff0c\u7136\u540e\u901a\u8fc7\u5b83\u6ce8\u518c\u5404\u79cdWSGI\u5f62\u5f0f\u7684\u51fd\u6570\u3002\n\u7f16\u5199\u8fd9\u4e9b\u51fd\u6570\u5e94\u8be5\u8d85\u7ea7\u7b80\u5355\u4e86\uff0c\u53ea\u8981\u4f60\u9075\u5faa start_response() \u51fd\u6570\u7684\u7f16\u5199\u89c4\u5219\uff0c\u5e76\u4e14\u6700\u540e\u8fd4\u56de\u5b57\u8282\u5b57\u7b26\u4e32\u5373\u53ef\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u5f53\u7f16\u5199\u8fd9\u79cd\u51fd\u6570\u7684\u65f6\u5019\u8fd8\u9700\u6ce8\u610f\u7684\u4e00\u70b9\u5c31\u662f\u5bf9\u4e8e\u5b57\u7b26\u4e32\u6a21\u677f\u7684\u4f7f\u7528\u3002\n\u6ca1\u4eba\u613f\u610f\u5199\u90a3\u79cd\u5230\u5904\u6df7\u5408\u7740 print() \u51fd\u6570 \u3001XML\u548c\u5927\u91cf\u683c\u5f0f\u5316\u64cd\u4f5c\u7684\u4ee3\u7801\u3002\n\u6211\u4eec\u4e0a\u9762\u4f7f\u7528\u4e86\u4e09\u5f15\u53f7\u5305\u542b\u7684\u9884\u5148\u5b9a\u4e49\u597d\u7684\u5b57\u7b26\u4e32\u6a21\u677f\u3002\n\u8fd9\u79cd\u65b9\u5f0f\u7684\u53ef\u4ee5\u8ba9\u6211\u4eec\u5f88\u5bb9\u6613\u7684\u5728\u4ee5\u540e\u4fee\u6539\u8f93\u51fa\u683c\u5f0f(\u53ea\u9700\u8981\u4fee\u6539\u6a21\u677f\u672c\u8eab\uff0c\u800c\u4e0d\u7528\u52a8\u4efb\u4f55\u4f7f\u7528\u5b83\u7684\u5730\u65b9)\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u6700\u540e\uff0c\u4f7f\u7528WSGI\u8fd8\u6709\u4e00\u4e2a\u5f88\u91cd\u8981\u7684\u90e8\u5206\u5c31\u662f\u6ca1\u6709\u4ec0\u4e48\u5730\u65b9\u662f\u9488\u5bf9\u7279\u5b9aweb\u670d\u52a1\u5668\u7684\u3002\n\u56e0\u4e3a\u6807\u51c6\u5bf9\u4e8e\u670d\u52a1\u5668\u548c\u6846\u67b6\u662f\u4e2d\u7acb\u7684\uff0c\u4f60\u53ef\u4ee5\u5c06\u4f60\u7684\u7a0b\u5e8f\u653e\u5165\u4efb\u4f55\u7c7b\u578b\u670d\u52a1\u5668\u4e2d\u3002\n\u6211\u4eec\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u6d4b\u8bd5\u6d4b\u8bd5\u672c\u8282\u4ee3\u7801\uff1a"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {},
      "outputs": [],
      "source": [
        "if __name__ == '__main__':\n    from wsgiref.simple_server import make_server\n\n    # Create the dispatcher and register functions\n    dispatcher = PathDispatcher()\n    pass\n\n    # Launch a basic server\n    httpd = make_server('', 8080, dispatcher)\n    print('Serving on port 8080...')\n    httpd.serve_forever()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "\u4e0a\u9762\u4ee3\u7801\u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u670d\u52a1\u5668\uff0c\u7136\u540e\u4f60\u5c31\u53ef\u4ee5\u6765\u6d4b\u8bd5\u4e0b\u4f60\u7684\u5b9e\u73b0\u662f\u5426\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002\n\u6700\u540e\uff0c\u5f53\u4f60\u51c6\u5907\u8fdb\u4e00\u6b65\u6269\u5c55\u4f60\u7684\u7a0b\u5e8f\u7684\u65f6\u5019\uff0c\u4f60\u53ef\u4ee5\u4fee\u6539\u8fd9\u4e2a\u4ee3\u7801\uff0c\u8ba9\u5b83\u53ef\u4ee5\u4e3a\u7279\u5b9a\u670d\u52a1\u5668\u5de5\u4f5c\u3002"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {},
      "source": [
        "WSGI\u672c\u8eab\u662f\u4e00\u4e2a\u5f88\u5c0f\u7684\u6807\u51c6\u3002\u56e0\u6b64\u5b83\u5e76\u6ca1\u6709\u63d0\u4f9b\u4e00\u4e9b\u9ad8\u7ea7\u7684\u7279\u6027\u6bd4\u5982\u8ba4\u8bc1\u3001cookies\u3001\u91cd\u5b9a\u5411\u7b49\u3002\n\u8fd9\u4e9b\u4f60\u81ea\u5df1\u5b9e\u73b0\u8d77\u6765\u4e5f\u4e0d\u96be\u3002\u4e0d\u8fc7\u5982\u679c\u4f60\u60f3\u8981\u66f4\u591a\u7684\u652f\u6301\uff0c\u53ef\u4ee5\u8003\u8651\u7b2c\u4e09\u65b9\u5e93\uff0c\u6bd4\u5982 WebOb \u6216\u8005 Paste"
      ]
    }
  ],
  "metadata": {
    "kernelspec": {
      "display_name": "Python 3",
      "language": "python",
      "name": "python3"
    },
    "language_info": {
      "codemirror_mode": {
        "name": "ipython",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.7.1"
    },
    "toc": {
      "base_numbering": 1,
      "nav_menu": {},
      "number_sections": true,
      "sideBar": true,
      "skip_h1_title": true,
      "title_cell": "Table of Contents",
      "title_sidebar": "Contents",
      "toc_cell": false,
      "toc_position": {},
      "toc_section_display": true,
      "toc_window_display": true
    }
  },
  "nbformat": 4,
  "nbformat_minor": 2
}